import request, { filterUsefulRequestParams } from '@/utils/request';
//  角色列表
export async function getRolelist(params) {
    return request('/api/oa/v1/role/getlist', {
        method: 'POST',
        data: params
    });
}
// 删除角色---携带角色id
export async function removeRole(id) {
    return request(`/api/oa/v1/role/delete/${id}`, {
        method: 'POST'
    });
}
// 角色详情
export async function getRoleDetail(id) {
    return request(`/api/oa/v1/role/getone/${id}`);
}
// 角色成员列表
export async function getRoleIdlist(roleId, companyId) {
    return request(`/api/oa/v1/role/getemployeelist/${roleId}/${companyId}`);
}

export async function removeRoleId(roleId, employeeId) {
    return request(`/api/oa/v1/role/deleteemployeerole/${roleId}/${employeeId}`, {
        method: 'POST'
    });
}
// 部门树
export async function getDepartmentTree(params) {
    return request(`/api/org/v1/functional/list?companyId=${params.companyId}`);
}
// 生成菜单树
export async function getMenuTree() {
    return request('/api/oa/v1/menu/selectmenutree');
}

// 添加角色
export async function addRoles(params) {
    return request('/api/oa/v1/role/saveorupdate', {
        method: 'POST',
        data: params
    });
}

// 职位管理列表
export async function getPostlist(params) {
    return request('/api/oa/v1/post/getlist', {
        method: 'POST',
        data: params
    });
}
// 删除职位
export async function removePost(id) {
    return request(`/api/oa/v1/post/delete/${id}`);
}
// 职位管理成员列表 [DELETE]
export async function getHostIdlist(id) {
    return request(`/api/oa/v1/post/getemployeebypostid/${id}`);
}
// 职位详情
export async function getPostType(params) {
    return request('/api/dict/v1/getList', {
        method: 'POST',
        data: params
    });
}
// 公司树
export async function CompanyTree() {
    return request('/api/org/v1/functional/list');
}

// 添加职位
export async function addPosturl(params) {
    return request('/api/oa/v1/post/saveorupdate', {
        method: 'POST',
        data: params
    });
}
// 编辑职位
export async function getPostIdDetail(id) {
    return request(`/api/oa/v1/post/getone/${id}`);
}

// 透视统计
export async function getOverviewData({ type }) {
    return request(`/api/gmstask/v1/gms/overview/new/${type}`, {
        method: 'GET'
    });
}

// 企业管理透视统计
export async function getOverviewWorkData({ type }) {
    return request(`/api/gmstask/v1/gms/overview/new/${type}`, {
        method: 'GET'
    });
}

// 行政管理透视
export async function getADMOverviewData({ companyId, reportType }) {
    return request('/api/gmstask/v1/gms/overview/xzoverview', {
        method: 'POST',
        data: { companyId, reportType }
    });
}

// HR管理透视
export async function getHROverviewData({ companyId, reportType }) {
    return request('/api/gmstask/v1/gms/overview/hroverview', {
        method: 'POST',
        data: { companyId, reportType }
    });
}

// 透视统计
export async function getWorkOverviewData({ companyId = 0, reportType = 0, startDate = '', endDate = '' }) {
    return request('/api/gmstask/v1/gms/overview/employee', {
        method: 'POST',
        data: { companyId, reportType, startDate, endDate }
    });
}

// 透视统计
export async function getProductOverviewData({ productId, reportType, startDate = '', endDate = '' }) {
    return request('/api/gmstask/v1/gms/overview/product', {
        method: 'POST',
        data: { productId, reportType, startDate, endDate }
    });
}

// ===============================新的职级=======================================

// 获取新职位列表
export async function getJobList(params) {
    // return request('/api/oa/v1/post/page', {
    return request('/api/uc/position/v1/getPage', {
        method: 'POST',
        data: params
    });
}

// 获取新职位详情
export async function getJobDetail(positionCode) {
    // return request(`/api/oa/v1/post/getPostDetail/${id}`, {
    return request(`/api/org/v1/position/detail/${positionCode}`, {
        method: 'GET'
    });
}

// 删除新职位
export async function deleteJob(params) {
    return request('/api/oa/v1/post/delPostToHiData', {
        method: 'POST',
        data: params
    });
}

// 删除职位前校验
export async function deleteJobCheck(positionCode) {
    return request(`/api/oa/v1/post/checkDeletePosition/${positionCode}`, {
        method: 'GET'
    });
}

// 添加新职位
export async function addJob(params) {
    // /api/oa/v1/post/addPost
    return request('/api/oa/v1/post/addPostToHiData', {
        method: 'POST',
        data: params
    });
}

// 编辑新职位
export async function updateJob(params) {
    return request('/api/oa/v1/post/updatePost', {
        method: 'POST',
        data: params
    });
}

// 职级列表
export async function getGradeList() {
    return request('/api/org/v1/rank/getPostGradeVoList', {
        method: 'POST'
    });
}
// 根据positionValue获取薪资参考标准
export async function getSalaryListByPositionValue(positionValue) {
    return request(`/api/oa/v1/post/getPostSalaryByPostCode/${positionValue}`, {
        method: 'GET'
    });
}
// 薪资参考标准
export async function getSalaryList(positionCode) {
    return request(`/api/oa/v2/post/getSalaryStandByPositionCode/${positionCode}`, {
        method: 'GET'
    });
}

// 薪资参考映射
export async function getSalaryStandByPostCodes(params) {
    return request('/api/oa/v1/post/getSalaryStandByPostCodes', {
        method: 'POST',
        data: params
    });
}

// 获取职位类别列表 - 包含一级和二级
export async function getPositionTypeList() {
    return request('/api/org/v1/position/type/list', {
        method: 'GET'
    });
}

// 获取授权树数据
export async function fetchDutyListByOrganizationCode(params) {
    return request('/api/uc/duty/v1/queryDutyListByOrganizationChoose', {
        method: 'POST',
        data: params
    });
}

// 根据机构编码查询机构树带岗位及员工
export async function fetchEmployeeListByOrganizationCode(params) {
    return request('/api/org/v1/organization/dutyEmployeeTree', {
        method: 'GET',
        params: filterUsefulRequestParams(params)
    });
}
